package j.framework.tags.easyui;

import j.framework.tags.form.FormTagWriter;
import j.util.StringUtils;

import javax.servlet.jsp.JspException;
import java.util.Map;

/**
 * easyui 之 上传文件控件
 * Created by junhai on 2015/1/17.
 */
public class FileBoxTag extends BaseEasyuiFormControl {
    private String buttonText;
    private String buttonAlign;

    @Override
    public void writeFormTagBegin(FormTagWriter writer) throws JspException {
        writer.beginTag("input");
    }

    @Override
    public void writeFormTagProperties(FormTagWriter writer) throws JspException {}

    @Override
    protected String getControlWidth() {
        return "100%";
    }

    @Override
    public void writeEasyuiDataOptions(Map<String, Object> dataOptions) throws JspException {
        if(StringUtils.isNotEmpty(buttonText)){
            dataOptions.put("buttonText",buttonText);
        }
        if(StringUtils.isNotEmpty(buttonAlign)){
            dataOptions.put("buttonAlign",buttonAlign);
        }
    }

    @Override
    public void endBeginTag(FormTagWriter writer) throws JspException {
        writer.closeBlankTag();
    }

    @Override
    public String getEasyuiClassName() {
        return "easyui-filebox";
    }

    public void setButtonText(String buttonText) {
        this.buttonText = buttonText;
    }

    public void setButtonAlign(String buttonAlign) {
        this.buttonAlign = buttonAlign;
    }
}
